<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('实验答疑，提问列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" name="experimentId" th:value="${experimentId}" id="experimentId">
                    <input type="hidden" name="userId" th:value="${userId}" id="userId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>问题内容：</p>
                                <input type="text" name="questionContent"/>
                            </li>
                            <li>
                                <p>是否回复：</p>
                                <select name="ifResponse">
                                    <option value="">请选择</option>
                                    <option value="1">否</option>
                                    <option value="2">是</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="addQuestion()">
                    <i class="fa fa-plus"></i> 添加
                </a>-->
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()">
                    <i class="fa fa-edit"></i> 回复
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <!--<a class="btn btn-warning" onclick="$.table.exportExcel()">
                    <i class="fa fa-download"></i> 导出
                 </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:question:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:question:remove')}]];
        var prefix = ctx + "system/question";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "实验提问",
                columns: [{
                    checkbox: true
                },
                    {
                        field : 'userName',
                        title : '用户名'
                    },
                {
                    field : 'questionContent',
                    title : '问题内容',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                    {
                        field : "createTime",
                        title: '提问时间'
                    },
                    {
                    field : 'ifResponse', 
                    title : '是否回复',
                        formatter: function (value, row, index) {
                            if(value == 1){
                                return "否";
                            }else{
                                return "是";
                            }
                        }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var userId = $("#userId").val();
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs " href="javascript:void(0)" onclick="lookAndAnswer(\'' + row.questionId + '\')"><i class="fa fa-lock"></i>回复</a> ');
                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.questionId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function addQuestion() {
            $.modal.open("提出问题",prefix + "/add?experimentId="+$("#experimentId").val(),600,600);
        }

        /**
         * 查看问题并回复
         */
        function lookAndAnswer(value){
            $.modal.open("提出问题",ctx + "/system/answer/lookAnswer?questionId="+value,1000,600);
        }
    </script>
</body>
</html>